#ifndef NETWORKACCESSMANAGER_H
#define NETWORKACCESSMANAGER_H

#include <QObject>
#include <QNetworkAccessManager>


//单例
class NetworkAccessManager : public QNetworkAccessManager
{
    Q_OBJECT
public:
    virtual ~NetworkAccessManager();


    static NetworkAccessManager *instance()
    {
        if(m_pNetworkAccessManager == nullptr)
            m_pNetworkAccessManager = new NetworkAccessManager;
        return m_pNetworkAccessManager;
    }

    static void release()
    {
        if(m_pNetworkAccessManager != nullptr)
            delete m_pNetworkAccessManager;
    }


private:
    explicit NetworkAccessManager(QObject *parent = nullptr);
    Q_DISABLE_COPY(NetworkAccessManager)

    static NetworkAccessManager *m_pNetworkAccessManager;
};

#endif // NETWORKACCESSMANAGER_H
